import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/3/29 8:10
 */

public class Solution {
    public int[] missingTwo(int[] nums) {
        //先把所有数异或在一起
        int tmp = 0;
        for (int x : nums) tmp ^= x;
        for (int i = 0; i <= nums.length + 2; i++) tmp ^= i;

        //找到a、b不同的那一位
        int diff = 0;
        while (true) {
            if (((tmp >> diff) & 1) == 1) break;
            else diff++;
        }

        //根据diff位不同，分为两类异或
        int[] ret = new int[2];
        for (int x : nums) {
            if (((x >> diff) & 1) == 1) ret[1] ^= x;
            else ret[0] ^= x;
        }
        for (int i = 0; i <= nums.length + 2; i++) {
            if (((i >> diff) & 1) == 1) ret[1] ^= i;
            else ret[0] ^= i;
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            int[] ret = solution.missingTwo(nums);
            System.out.println(Arrays.toString(ret));
        }
    }
}